import axios from 'axios'
import config from './config'
import ENV from './apiList'
//
// axios(config);
function API() {
    //获取已授权列表
    this.Boot = function(param, url, diyurl) {
        config.data.data = param.data;
        switch (ENV.APILIST[url]) {
            case undefined:
                //
                break;
            case 'diy':
                return axios.post(diyurl, {}, config);
                break;
            default:
                return axios.post(ENV.APILIST[url], {}, config);
                break;
        }
    }
  this.get = function(param) {
            // config.data.data = param.data;
            return axios.get(config.baseURL + ENV.APILIST[param.api], param.data, config);
        }
        //添加授权
  this.post = function(param) {
          if(param.page){
            return axios.post(ENV.APILIST[param.api]+'?page='+param.page, param.data, config);
          }  else{
            return axios.post(ENV.APILIST[param.api], param.data, config);
          }
    }

  this.reqSuccess= function(obj, msg) {
        obj.$message({
            message: msg,
            fuck: 'feifei',
            type: 'success'
        });
    }
  this.reqFail= function(obj, msg) {
        obj.$message({
            message: msg,
            type: 'success'
        });
    }
}
export default API;
